﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using DTN.Core;
using Hanel.DTN.News;

public partial class Control_Menu : System.Web.UI.UserControl
{
    ItblOS_Crawer_ChannelsManager obj = tblOS_Crawer_ChannelsManager.CreateInstance();
   
    protected void Page_Load(object sender, EventArgs e)
    {
        DisplayMenuXaHoi();
        DisplayMenuVanHoa();
        DisplayMenuTheThao();
        DisplayMenuTheGioi();
        DisplayMenuViTinh();
        DisplayMenuKhoaHoc();
        DisplayMenuPhapLuat();
        DisplayMenuOto();
       

    }
   
    protected void DisplayMenuXaHoi()
    {
        DataTable dt = obj.SelectOS_Crawer_ChannelsDynamic("ParentID=97", "ID desc");
        DataList1.DataSource = dt;
        DataList1.DataBind();
        HyperLink1.NavigateUrl = "~/News.aspx?parent=97";
    }

    protected void DisplayMenuVanHoa()
    {
        DataTable dt = obj.SelectOS_Crawer_ChannelsDynamic("ParentID=48", "ID desc");
        DataList2.DataSource = dt;
        DataList2.DataBind();
        HyperLink2.NavigateUrl = "~/News.aspx?parent=48";
        DataList9.DataSource = dt;
        DataList9.DataBind();
    }
    protected void DisplayMenuTheThao()
    {
        DataTable dt = obj.SelectOS_Crawer_ChannelsDynamic("ParentID=98", "ID desc");
        DataList3.DataSource = dt;
        DataList3.DataBind();
        HyperLink3.NavigateUrl = "~/News.aspx?parent=98";
    }

    protected void DisplayMenuTheGioi()
    {
        DataTable dt = obj.SelectOS_Crawer_ChannelsDynamic("ParentID=108", "ID desc");
        DataList4.DataSource = dt;
        DataList4.DataBind();
        HyperLink4.NavigateUrl = "~/News.aspx?parent=108";
    }

    protected void DisplayMenuViTinh()
    {
        DataTable dt = obj.SelectOS_Crawer_ChannelsDynamic("ParentID=86", "ID desc");
        DataList5.DataSource = dt;
        DataList5.DataBind();
        HyperLink5.NavigateUrl = "~/News.aspx?parent=86";
    }
    protected void DisplayMenuKhoaHoc()
    {
        DataTable dt = obj.SelectOS_Crawer_ChannelsDynamic("ParentID=83", "ID desc");
        DataList6.DataSource = dt;
        DataList6.DataBind();
        HyperLink6.NavigateUrl = "~/News.aspx?parent=83";
    }

    protected void DisplayMenuPhapLuat()
    {
        DataTable dt = obj.SelectOS_Crawer_ChannelsDynamic("ParentID=78", "ID desc");
        DataList7.DataSource = dt;
        DataList7.DataBind();
        HyperLink7.NavigateUrl = "~/News.aspx?parent=78";
    }

    protected void DisplayMenuOto()
    {
        DataTable dt = obj.SelectOS_Crawer_ChannelsDynamic("ParentID=90", "ID desc");
        DataList8.DataSource = dt;
        DataList8.DataBind();
        HyperLink8.NavigateUrl = "~/News.aspx?parent=90";

       
    }
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        string[] Words = txtKey.Text.Split(' ');

        string sTemp = string.Empty;
        string sReturn = string.Empty;

        for (int i = 0; i < Words.Length; i++)
        {
            sTemp += Words.GetValue(i).ToString();
        }
        sReturn = sTemp.ToString();


        if (this.txtKey.Text == null || sReturn.ToString() == "")
        {
            Response.Write("<script type='text/javascript'>alert('Bạn chưa nhập từ khóa tìm kiếm');location.href='default.aspx';</script>");
            //Response.Redirect("Default.aspx");
        }
        else
        {
            Response.Redirect("News.aspx?key=" + txtKey.Text);
        }
    }
    
}